<?php 
if(isset($_GET['id'])){
	$id	=	$_GET['id'];
	$q	=	mysql_query("SELECT * FROM phanloai WHERE `pl_id`=".intval($id));
	$row	=	mysql_fetch_array($q);
	
}
?>
<div class="mainright">
	<div class="tableout">
	
			<div class="title1">
	            <div class="column" style="width:100%;">Cập nhật chuyên mục</div>
	        </div>
	
			<div class="editcate_ct">
			
			    <form method="post" action="" enctype="multipart/form-data" id="news_form">
			    
			    <div id="div_message"></div>
			    
				<div class="boxadd">
			    	<ul class="linect">
			        
			        <li>
			        	<span class="left"><b>Tên chuyên mục</b></span>
			        	<span class="right"><input name="name" value="<?php echo (isset($_POST['name']) ? $_POST['name'] :(isset($row) ? $row['pl_title'] : ''));?>" style="width: 40%; margin: 0pt;" type="text"></span>
			        </li>
			
			        </ul>
			    </div>
			    <div class="btarticle">
			    	<input onclick="$('#light_adct, #fade_adct').hide();" value="Thoát" class="btn" type="button">
			        <input name="" value="Cập nhật" class="btn" type="submit">
			    </div>
			    
			    </form>
			    
			</div>
	</div>
	
	
	<?php 
	if($_SERVER['REQUEST_METHOD'] == 'POST'){
		$name	=	$_POST['name'];
		if(isset($_GET['id']) && $_GET['id'] > 0){
			mysql_query("UPDATE phanloai SET `pl_title`='$name' WHERE `pl_id`=".intval($_GET['id']));
		}else{
			mysql_query("INSERT INTO phanloai(`pl_title`)VALUES('$name')");
		}	
		
	}
	?>
	
	<div class="tableout">
		<div class="title1">
	            <div class="column" style="width:100%;">Danh sách chuyên mục</div>
	    </div>
	    <div class="toppage">
	    	<span class="left">
	        	<select style="width:130px;">
	            	<option value="1">Action</option>
	                <option value="2">Edit</option>
	                <option value="3">Delete</option>
	            </select>
	            <input type="submit" name="" value="Apply" class="btn" />
	            <input type="text" name="" value="Keyword" style="width:165px; padding:3px;" />
	            <input type="text" name="" value="Date/time" style="width:165px; padding:3px;" />
	            <select style="width:130px; line-height:25px;">
	            	<option value="1">Destinations</option>
	                <option value="2">Hanoi</option>
	                <option value="3">Hue</option>
	                <option value="4">Da Nang</option>
	                <option value="5">TP.HCM</option>
	            </select>
	            <select style="width:130px; line-height:25px;">
	            	<option value="1">Tours styles</option>
	                <option value="2">City Tours</option>
	                <option value="3">Honeymoon Tours</option>
	                <option value="4">Join Group Tops</option>
	                <option value="5">Culture Tour</option>
	            </select>
	            <input type="submit" name="" value="Filter" class="btn" />
	        </span>
	        <span class="btnadd"><a href="#">Add new tour</a></span>
	    </div>
	    
	    <div class="topart">
	    	<span class="left">
	    		<font class="number">(23265)</font> <a href="javascript:;">All</a><font class="line">|</font><font class="number">(1120)</font> <a href="javascript:;"><font color="#0b9901">Active</font></a><font class="line">|</font><font class="number">(5)</font> <a href="javascript:;"><font color="#c60001">Pending</font></a><font class="line">|</font><font class="number">(15)</font><a href="javascript:;"> Draft</a>
	        </span>
	        <span class="right1">
	        	<select style="width:50px;">
	            	<option value="1">30</option>
	                <option value="2">50</option>
	                <option value="3">100</option>
	            </select>
	            <div class="pagination">
	                <ul>
	                    <li><a href="#" class="prevnext disablelink">« Prev</a></li>
	                    <li><a href="#" class="currentpage">1</a></li>
	                    <li><a href="#">2</a></li>
	                    <li><a href="#">3</a></li>
	                    <li><a href="#">4</a></li>
	                    <li><a href="#">5</a>...</li>
	                    <li><a href="#">15</a></li>
	                    <li><a href="#">16</a></li>
	                    <li><a href="#" class="prevnext">Next »</a></li>
	                </ul>
	            </div>
	        </span>
	        
	    </div>
	    
	    <div class="tableout">
			<div class="title1">
	        	<div class="column" style="width:2%;"><input type="checkbox" name="" value="" /></div>
	            <div class="column" style="width:2%;">No</div>
	            <div class="column" style="width:80%;">Tên chuyên mục</div>
	        </div>
	        <?php 
	        $q	=	mysql_query("SELECT * FROM phanloai");
	        $i=1;
	        ?>
	        <?php while($result	=	mysql_fetch_array($q)):?>
	        <div class="linecate2">
	        	<div class="column" style="width:2%;"><input type="checkbox" name="" value="" /></div>
	            <div class="column" style="width:2%;"><?php echo $i;?></div>
	            <div class="column" style="width:80%;" onmouseover="Hovercat('<?php echo $result['pl_id']?>')" onmouseout="Outcat('<?php echo $result['pl_id']?>')">
	            	<a href="javascript:;" class="art"><?php echo $result['pl_title'];?></a><br />
	                <div class="action" id="neocat-<?php echo $result['pl_id']?>">
	                    <img src="images/edit.gif" /><a href="index.php?act=update_cat&id=<?php echo $result['pl_id'];?>">Edit</a>|<img src="images/preview.gif" /><a href="javascript:void(0)" onclick ="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">Preview</a>|<img src="images/delete.gif" /><a href="#"><font color="#be0000">Delete</font></a>
	                </div>
	            </div>
	           
	        </div>
	        <?php $i++;?>
	        <?php endwhile;?>
	        
	        <div class="bottom1">
	        	<div class="column" style="width:2%;"><input type="checkbox" name="" value="" /></div>
	            <div class="column" style="width:50%;">
	            	<select style="width:130px;">
	                    <option value="1">Action</option>
	                    <option value="2">Edit</option>
	                    <option value="3">Delete</option>
	                </select>
	                <input type="submit" name="" value="Apply" class="btn" />
	            </div>
	            <span class="right1">
	                <div class="pagination">
	                    <ul>
	                        <li><a href="#" class="prevnext disablelink">« Prev</a></li>
	                        <li><a href="#" class="currentpage">1</a></li>
	                        <li><a href="#">2</a></li>
	                        <li><a href="#">3</a></li>
	                        <li><a href="#">4</a></li>
	                        <li><a href="#">5</a>...</li>
	                        <li><a href="#">15</a></li>
	                        <li><a href="#">16</a></li>
	                        <li><a href="#" class="prevnext">Next »</a></li>
	                    </ul>
	                </div>
	            </span>
	        </div>
	        
	    </div>
    </div>

</div>


